import math

n, k = map(int, input().split())
nums = list(map(int, input().split()))
p = [(num.bit_length()) for num in nums]
minus = [(1<<p[i])-nums[i] for i in range(n)]
sums_minus = sum(minus)
sums_p = sum(p)
ans = float('inf')
